<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>修改密码</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function passwordLevel(password) {
			var Modes = 0;
			for (i = 0; i < password.length; i++) {
				Modes |= CharMode(password.charCodeAt(i));
			}
			return bitTotal(Modes);
			//CharMode函数
			function CharMode(iN) {
				if (iN >= 48 && iN <= 57)//数字
					return 1;
				if (iN >= 65 && iN <= 90) //大写字母
					return 2;
				if ((iN >= 97 && iN <= 122) || (iN >= 65 && iN <= 90))
				//大小写
					return 4;
				else
					return 8; //特殊字符
			}
			//bitTotal函数
			function bitTotal(num) {
				modes = 0;
				for (i = 0; i < 4; i++) {
					if (num & 1) modes++;
					num >>>= 1;
				}
				return modes;
			}
		}
		$(document).ready(function() {
			$.validator.addMethod("strongPsw",function(value,element){
				if(passwordLevel(value)==1){
					return false;
				}else{
					return true
				}
			},"请输入数字+字母大小写混合密码");
			$("#oldPassword").focus();
			$("#inputForm").validate({
				rules: {
					newPassword:{
						required:true, //必填
						minlength:6, //最小长度
						maxlength:32, //最大长度
						strongPsw:true, //密码强度
					},
					confirmNewPassword:{
						required:true,
						minlength:6,
						maxlength:32,
						equalTo:"#newPassword" //再次填写密码需一致
					}
				},
				messages: {
					confirmNewPassword: {equalTo: "输入与上面相同的密码"}
				},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>

</head>
<body>
<ul class="nav nav-tabs">
	<li><a href="${ctx}/sys/user/info">个人信息</a></li>
	<li class="active"><a href="${ctx}/sys/user/modifyPwd">修改密码</a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="user" action="${ctx}/sys/user/modifyPwd" method="post" class="form-horizontal">
	<form:hidden path="id"/>
	<sys:message content="${message}"/>
	<div class="control-group">
		<label class="control-label">旧密码:</label>
		<div class="controls">
			<input id="oldPassword" name="oldPassword" type="password" value="" maxlength="50" minlength="3" class="required"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">新密码:</label>
		<div class="controls">
			<input id="newPassword" name="newPassword" type="password" value="" maxlength="50" minlength="3" class="required"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">确认新密码:</label>
		<div class="controls">
			<input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50" minlength="3" class="required" equalTo="#newPassword"/>
			<span class="help-inline"><font color="red">*</font> </span>
		</div>
	</div>
	<div class="form-actions">
		<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
	</div>
</form:form>
</body>
</html>